/**
  ******************************************************************************
  * File Name          : taskctrl.c
  * Description        : Code for freertos applications
  ******************************************************************************
  * @attention
  *
  ******************************************************************************
  */

/* Includes ------------------------------------------------------------------*/
#include "bsp.h"
#include "tskcfg.h"
#include "route_expio_485.h"
#include <string.h>
/*------------ task define ------------*/

TaskHandle_t xRunDog_Thd = NULL;
StaticTask_t xRunDog_Tcb;
StackType_t  xRunDog_Stk[ RUNDOG_STACK_SIZE ];

/**
  * @brief  Create task
  * @param  None
  * @retval None
  */
void APP_CreateTask(void)
{
	xRunDog_Thd = xTaskCreateStatic(vRunDog_Task,
	                                 "RunD",
	                                 RUNDOG_STACK_SIZE,
	                                 (void *)1,
																	 RUNDOG_TSK_PRIORITY,
																	 xRunDog_Stk,
																	 &xRunDog_Tcb);

//	xTerminal_Thd = xTaskCreateStatic(vTerminal_Task,
//																	  "term",
//																	  TTY_STACK_SIZE,
//																	  (void *)1,
//																	  TTY_TSK_PRIORITY,
//																	  xTerminal_Stk,
//																	  &xTerminal_Tcb);

  xStoragePara_Thd = xTaskCreateStatic(vStoragePara_Task,
										                   "para",
																	     STGPARA_STACK_SIZE,
																	     (void *)1,
																	     STGPARA_TSK_PRIORITY,
																	     xStoragePara_Stk,
																	     &xStoragePara_Tcb);	
}

void vRunDog_Task( void * pvParameters )
{
  uint8_t step = 0;
  
  Route_SubDevInstructLed();
  
  vTaskDelay(1000);
  
  Expio_DevTaskCreat();
  
  xRoute_485_Thd = xTaskCreateStatic(vRoute_485_Task,
																	  "r485",
																 	  ROUTE_485_STACK_SIZE,
																	  (void *)1,
																	  ROUTE_485_TSK_PRIORITY,
																	  xRoute_485_Stk,
																	  &xRoute_485_Tcb);
                                    
	while(1)
	{
		Sys_RunLed();
    
		Sys_GetDataTime();
    
    if(step >= 10)
    {
      LL_IWDG_ReloadCounter(IWDG);
      step = 0;
    }
    
    step++;
	}
}

/* GetIdleTaskMemory prototype (linked to static allocation support) */
void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize );

static StaticTask_t xIdleTaskTCBBuffer;
static StackType_t xIdleStack[configMINIMAL_STACK_SIZE];

void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize )
{
  *ppxIdleTaskTCBBuffer = &xIdleTaskTCBBuffer;
  *ppxIdleTaskStackBuffer = &xIdleStack[0];
  *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
}

/* Private application code --------------------------------------------------*/

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
